home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Internet Tools 1993 July / Internet Tools.iso / RockRidge / mail / pp / pp-6.0 / Tools / tables / rfc987-pp / awk.rfc987.pac next >
Encoding:
Text File  |  1991-12-18  |  912 b   |  58 lines

  1. #!/bin/sh
  2. #
  3. #
  4. #       awk.rfc987 - is an awk program that reformats the
  5. #       RFC-987 International tables into PP ones.
  6. #
  7. #
  8. #       syntax :    awk.rfc987  input-table
  9. #
  10. ######################################################################
  11.  
  12.  
  13. AWK=/usr/bin/awk
  14.  
  15. FILE=$1
  16.  
  17. if [ -z "$FILE" ]
  18. then
  19.         echo " "
  20.         echo "Usage:   awk.rfc987 input-table"
  21.         echo " "
  22.         exit 1
  23. fi
  24.  
  25.  
  26.  
  27.  
  28.  
  29. #---------------------- Start of the awk routines  --------------------------#
  30.  
  31.  
  32. $AWK <$FILE '
  33. BEGIN   {
  34.                 FS ="#"
  35.         }
  36. /^#.*/  {
  37.                 print $0
  38.         next
  39.         }
  40.         {
  41.         if ((n = split($1, array, ":")) > 1) {
  42.            for (i = 1; i < n; i++)
  43.                printf("%s\:",array[i])
  44.            printf("%s", array[n]);
  45.                 } else
  46.            printf("%s", $1)
  47.  
  48.         printf(":");
  49.  
  50.         printf("%s", $2)
  51.         for (i = 3; i < NF; i++)
  52.             printf("#%s", $i);
  53.         printf("\n");
  54.         next
  55.         }
  56. END     {}
  57. '
  58.